package com.example.demo1122.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo1122.entity.Conversation;
import com.example.demo1122.entity.Teacherforclass;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author baomidou
 * @since 2023-12-21
 */
@Mapper
public interface TeacherforclassMapper extends BaseMapper<Teacherforclass> {
    @Select("SELECT COUNT(*) FROM teacherforclass WHERE classID = #{classID} AND teacherID = #{teacherID}")
    int countByClassIdAndTeacherId(Integer classID, String teacherID);

    @Insert("INSERT into teacherforclass(teacherID, teacherName, classID) VALUES (#{teacherID}, #{teacherName}, #{classID})")
    int insert(Teacherforclass teacherforclass);
    @Delete("DELETE FROM teacherforclass WHERE classID = #{classID} AND teacherID = #{teacherID}")
    int deleteByClassIdAndTeacherId(Integer classID, String teacherID);

    List<String> selectClassIdsByTeacherID(@Param("teacherID") String teacherID);

    List<String> selectTeacherIdsByClassId(Integer classID);
    @Select("SELECT COUNT(*) FROM teacherforclass WHERE teacherID = #{teacherID}")
    int countByTeacherId(String teacherID);

    List<Conversation> getStudentConversationList(String studentID, Integer classID, Integer chapterID);
}
